﻿namespace Rosieks.Web.Flow.Fluent
{
    using System;
    using System.Collections.Generic;
    using Rosieks.Web.Flow.Metadata;

    public static class FluentRegistration
    {
        public static WebflowModel<TWebflowModel> RegisterStates<TWebflowModel>(this WebflowModel<TWebflowModel> model, Action<FluentStateRegister<TWebflowModel>> states)
        {
            model.States = new List<State>();

            var register = new FluentStateRegister<TWebflowModel>(model);

            states(register);

            register.Execute();

            return model;
        }

        public static FluentStateRegister<TState, TWebflowModel> WithView<TState, TWebflowModel>(this FluentStateRegister<TState, TWebflowModel> register, string viewPath) where TState : ViewState
        {
            register.State.ViewPath = viewPath;

            return register;
        }
    }
}
